<script setup lang="ts">
import { ref } from 'vue'

const props = defineProps({
  btnList: Array as any
})

// 定义向父组件发送到事件
const emit = defineEmits([
  'peizhiFn',
  'addFn',
  'addKnowledgeBaseFn',
  'reportForRepairFn',
  'projectInfoFn',
  'equipmentItemsFn',
  'equipmentMaintenanceFn',
  'equipmentSpotCheckFn',
  'equipmentInspectionFn',
  'fileManagementFn',
  'deliveryDeliveryFn',
  'handoverWarehousingFn',
  'equipmentMaintainFn',
  'dispatchFn',
  'verificationFn',
  'maintenanceRecordFn',
  'deviceAssociationFn',
  'disassociateFn',
  'inspectionEditinFn',
  'materialHandoverFn',
  'toOnlineFn',
  'transferOrderFn',
  'maintenanceFn',
  'confirmFn',
  'releaseFn',
  'submittoFn',
  'purchaseOrderFn',
  'editFn',
  'hangFn',
  'delFn',
  'dieScrapFn',
  'scrapFn',
  'revokeFn',
  'terminationFn',
  'rebackFn',
  'closeFn',
  'testFn',
  'searchFn',
  'recoveryFn',
  'finishedProductTransferOrderFn',
  'resetFn',
  'backFn',
  'clearFn',
  'runFn',
  'exportFn',
  'examineFn',
  'contractUpdateFn',
  'submitForReviewFn',
  'exportTemplateFn',
  'importFn'
])

// 文件导入列表
const fileList = ref([])

// 配置按钮事件
const peizhiFn = () => {
  emit('peizhiFn')
}

// 新增按钮点击事件
const addFn = () => {
  emit('addFn')
}

// 添加知识库
const addKnowledgeBaseFn = () => {
  emit('addKnowledgeBaseFn')
}

// 报修
const reportForRepairFn = () => {
  emit('reportForRepairFn')
}

// 项目信息
const projectInfoFn = () => {
  emit('projectInfoFn')
}

// 设备项目
const equipmentItemsFn = () => {
  emit('equipmentItemsFn')
}

// 设备保养
const equipmentMaintenanceFn = () => {
  emit('equipmentMaintenanceFn')
}

// 设备点检
const equipmentSpotCheckFn = () => {
  emit('equipmentSpotCheckFn')
}

// 设备巡检
const equipmentInspectionFn = () => {
  emit('equipmentInspectionFn')
}

// 文件管理
const fileManagementFn = () => {
  emit('fileManagementFn')
}

// 交移出库
const deliveryDeliveryFn = () => {
  emit('deliveryDeliveryFn')
}

// 交接入库
const handoverWarehousingFn = () => {
  emit('handoverWarehousingFn')
}

// 设备维护
const equipmentMaintainFn = () => {
  emit('equipmentMaintainFn')
}

// 派工
const dispatchFn = () => {
  emit('dispatchFn')
}

// 验证
const verificationFn = () => {
  emit('verificationFn')
}

// 维修记录
const maintenanceRecordFn = () => {
  emit('maintenanceRecordFn')
}

// 设备关联
const deviceAssociationFn = () => {
  emit('deviceAssociationFn')
}

// 解除关联
const disassociateFn = () => {
  emit('disassociateFn')
}

// 检验编辑
const inspectionEditinFn = () => {
  emit('inspectionEditinFn')
}

// 物料交接
const materialHandoverFn = () => {
  emit('materialHandoverFn')
}

// 上线按钮
const toOnlineFn = () => {
  emit('toOnlineFn')
}

// 转单
const transferOrderFn = () => {
  emit('transferOrderFn')
}

// 物料类别维护
const maintenanceFn = () => {
  emit('maintenanceFn')
}

// 确认按钮
const confirmFn = () => {
  emit('confirmFn')
}

// 手动下达按钮
const releaseFn = () => {
  emit('releaseFn')
}

// 提交按钮
const submittoFn = () => {
  emit('submittoFn')
}

// 采购下单
const purchaseOrderFn = () => {
  emit('purchaseOrderFn')
}

// 修改按钮点击事件
const editFn = () => {
  emit('editFn')
}

// 挂起
const hangFn = () => {
  emit('hangFn')
}

// 删除按钮点击事件
const delFn = () => {
  emit('delFn')
}

// 模具报废
const dieScrapFn = () => {
  emit('dieScrapFn')
}

// 设备报废
const scrapFn = () => {
  emit('scrapFn')
}

// 撤销
const revokeFn = () => {
  emit('revokeFn')
}

// 终止按钮
const terminationFn = () => {
  emit('terminationFn')
}

// 退回按钮
const rebackFn = () => {
  emit('rebackFn')
}

// 关结按钮
const closeFn = () => {
  emit('closeFn')
}

// 查询按钮
const searchFn = () => {
  emit('searchFn')
}

// 恢复
const recoveryFn = () => {
  emit('recoveryFn')
}

// 成品转单
const finishedProductTransferOrderFn = () => {
  emit('finishedProductTransferOrderFn')
}

// 重置按钮
const resetFn = () => {
  emit('resetFn')
}

// 返回按钮
const backFn = () => {
  emit('backFn')
}

// 立即执行按钮
const runFn = () => {
  emit('runFn')
}

// 导出按钮
const exportFn = () => {
  emit('exportFn')
}

// 合同上传
const contractUpdateFn = () => {
  emit('contractUpdateFn')
}

// 审核按钮
const examineFn = () => {
  emit('examineFn')
}

// 提交审核
const submitForReviewFn = () => {
  emit('submitForReviewFn')
}

// 导出模板按钮
const exportTemplateFn = () => {
  emit('exportTemplateFn')
}

// 清空按钮
const clearFn = () => {
  emit('clearFn')
}

// 测试按钮
const testFn = () => {
  emit('testFn')
}

// 导入文件Change
const importFn = (e: any) => {
  emit('importFn', e)
}
</script>

<template>
  <div class="btnBox">
    <div v-for="item in props.btnList" :key="item.type">
      <a-button
        v-if="item.type == 'peizhi'"
        :disabled="item.disabled"
        color="#626aef"
        style="color: white"
        size="small"
        @click="peizhiFn"
      >
        配置
      </a-button>
      <a-button
        v-if="item.type == 'add'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="addFn"
      >
        新增
      </a-button>
      <a-button
        v-if="item.type == 'addKnowledgeBase'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="addKnowledgeBaseFn"
      >
        添加知识库
      </a-button>

      <a-button
        v-if="item.type == 'reportForRepair'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="reportForRepairFn"
      >
        报修
      </a-button>

      <a-button
        v-if="item.type == 'projectInfo'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="projectInfoFn"
      >
        项目信息
      </a-button>
      <a-button
        v-if="item.type == 'equipmentItems'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="equipmentItemsFn"
      >
        设备项目
      </a-button>
      <a-button
        v-if="item.type == 'equipmentMaintenance'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="equipmentMaintenanceFn"
      >
        设备保养
      </a-button>
      <a-button
        v-if="item.type == 'equipmentSpotCheck'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="equipmentSpotCheckFn"
      >
        设备点检
      </a-button>
      <a-button
        v-if="item.type == 'equipmentInspection'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="equipmentInspectionFn"
      >
        设备巡检
      </a-button>
      <a-button
        v-if="item.type == 'fileManagement'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="fileManagementFn"
      >
        文件管理
      </a-button>
      <a-button
        v-if="item.type == 'deliveryDelivery'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="deliveryDeliveryFn"
      >
        交移出库
      </a-button>
      <a-button
        v-if="item.type == 'handoverWarehousing'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="handoverWarehousingFn"
      >
        交接入库
      </a-button>
      <a-button
        v-if="item.type == 'equipmentMaintain'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="equipmentMaintainFn"
      >
        设备维护
      </a-button>

      <a-button
        v-if="item.type == 'dispatch'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="dispatchFn"
      >
        派工
      </a-button>
      <a-button
        v-if="item.type == 'verification'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="verificationFn"
      >
        验证
      </a-button>
      <a-button
        v-if="item.type == 'maintenanceRecord'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="maintenanceRecordFn"
      >
        维修记录
      </a-button>

      <a-button
        v-if="item.type == 'deviceAssociation'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="deviceAssociationFn"
      >
        设备关联
      </a-button>
      <a-button
        v-if="item.type == 'disassociate'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="disassociateFn"
      >
        解除关联
      </a-button>

      <a-button
        v-if="item.type == 'inspectionEditing'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="inspectionEditinFn"
      >
        检验编辑
      </a-button>
      <a-button
        v-if="item.type == 'materialHandover'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="materialHandoverFn"
      >
        物料交接
      </a-button>
      <a-button
        v-if="item.type == 'toOnline'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="toOnlineFn"
      >
        上线
      </a-button>
      <a-button
        v-if="item.type == 'transferOrder'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="transferOrderFn"
      >
        转单
      </a-button>
      <a-button
        v-if="item.type == 'maintenance'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="maintenanceFn"
      >
        物料类别维护
      </a-button>
      <a-button
        v-if="item.type == 'confirm'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="confirmFn"
      >
        确认
      </a-button>
      <a-button
        v-if="item.type == 'release'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="releaseFn"
      >
        手动下达
      </a-button>
      <a-button
        v-if="item.type == 'submitto'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="submittoFn"
      >
        提交
      </a-button>
      <a-button
        v-if="item.type == 'purchaseOrder'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="purchaseOrderFn"
      >
        采购下单
      </a-button>
      <a-button
        v-if="item.type == 'edit'"
        :disabled="item.disabled"
        status="warning"
        size="small"
        plain
        @click="editFn"
      >
        修改
      </a-button>
      <a-button
        v-if="item.type == 'hang'"
        :disabled="item.disabled"
        status="warning"
        size="small"
        plain
        @click="hangFn"
      >
        挂起
      </a-button>
      <el-popconfirm
        v-if="item.type == 'remove'"
        title="删除确认"
        @confirm="delFn"
      >
        <template #reference>
          <a-button
            size="small"
            :disabled="item.disabled"
            status="danger"
            plain
          >
            删除
          </a-button>
        </template>
      </el-popconfirm>
      <a-button
        v-if="item.type == 'dieScrap'"
        size="small"
        :disabled="item.disabled"
        status="danger"
        plain
        @click="dieScrapFn"
      >
        模具报废
      </a-button>

      <a-button
        v-if="item.type == 'scrap'"
        size="small"
        :disabled="item.disabled"
        status="danger"
        plain
        @click="scrapFn"
      >
        设备报废
      </a-button>
      <a-button
        v-if="item.type == 'revoke'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="revokeFn"
      >
        撤销
      </a-button>
      <a-button
        v-if="item.type == 'termination'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="terminationFn"
      >
        终止
      </a-button>
      <a-button
        v-if="item.type == 'reback'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="rebackFn"
      >
        退回
      </a-button>
      <a-button
        v-if="item.type == 'close'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="closeFn"
      >
        关结
      </a-button>
      <a-button
        v-if="item.type == 'search'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="searchFn"
      >
        查询
      </a-button>
      <a-button
        v-if="item.type == 'recovery'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="recoveryFn"
      >
        恢复
      </a-button>
      <a-button
        v-if="item.type == 'finishedProductTransferOrder'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="finishedProductTransferOrderFn"
      >
        成品转单
      </a-button>

      <a-button
        v-if="item.type == 'reset'"
        :disabled="item.disabled"
        size="small"
        plain
        @click="resetFn"
      >
        重置
      </a-button>
      <a-button
        v-if="item.type == 'test'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="testFn"
      >
        测试
      </a-button>
      <a-button
        v-if="item.type == 'back'"
        :disabled="item.disabled"
        type="primary"
        size="small"
        plain
        @click="backFn"
      >
        返回
      </a-button>
      <a-button
        v-if="item.type == 'clear'"
        :disabled="item.disabled"
        status="danger"
        size="small"
        plain
        @click="clearFn"
      >
        清空
      </a-button>
      <a-button
        v-if="item.type == 'run'"
        :disabled="item.disabled"
        status="success"
        size="small"
        plain
        @click="runFn"
      >
        立即执行
      </a-button>
      <a-button
        v-if="item.type == 'export'"
        :disabled="item.disabled"
        status="success"
        size="small"
        @click="exportFn"
      >
        导出
      </a-button>
      <a-button
        v-if="item.type == 'examine'"
        :disabled="item.disabled"
        status="success"
        size="small"
        @click="examineFn"
      >
        审核
      </a-button>
      <a-button
        v-if="item.type == 'contractUpdate'"
        :disabled="item.disabled"
        status="success"
        size="small"
        @click="contractUpdateFn"
      >
        合同上传
      </a-button>

      <a-button
        v-if="item.type == 'submitForReview'"
        :disabled="item.disabled"
        status="success"
        size="small"
        @click="submitForReviewFn"
      >
        提交审核
      </a-button>
      <a-button
        v-if="item.type == 'exportTemplate'"
        :disabled="item.disabled"
        status="success"
        size="small"
        @click="exportTemplateFn"
      >
        模板导出
      </a-button>
      <a-upload
        v-if="item.type == 'import'"
        style="width: 60px"
        action=""
        accept=".xls,.xlsx"
        :auto-upload="false"
        :show-file-list="false"
        :limit="1"
        :file-list="fileList"
        :on-change="importFn"
      >
        <template #upload-button>
          <a-button size="small" type="primary">导入</a-button>
        </template>
      </a-upload>
    </div>
  </div>
</template>

<style scoped lang="less">
.btnBox {
  display: flex;
  flex-direction: row;
  margin-bottom: 10px;

  .arco-btn {
    margin-left: 5px;
  }
}
</style>
